package com.d3works.studio.web;

import com.d3works.inject.Beans;
import com.d3works.meta.db.MetaSelect;
import com.d3works.rpc.ActionRequest;
import com.d3works.rpc.ActionResponse;
import com.d3works.studio.service.builder.SelectionBuilderService;

public class SelectionBuilderController {

  public void fillSelectionText(ActionRequest request, ActionResponse response) {

    MetaSelect metaSelect = (MetaSelect) request.getContext().get("metaSelect");

    if (metaSelect != null) {
      String name = metaSelect.getName();
      response.setValue(
          "selectionText", Beans.get(SelectionBuilderService.class).createSelectionText(name));
      response.setValue("name", name);
    } else {
      response.setValue("selectionText", null);
      response.setValue("name", null);
    }
  }
}
